﻿using System;
using System.ComponentModel;
using System.Drawing.Design;
using System.Web.UI.Design;
using Coolite.Ext.Web;

namespace Pap.Web.Utils
{
    /// <summary>
    /// 
    /// </summary>
    public class HyperLinkMenuItem : MenuItem
    {
        /// <summary>
        /// Gets or sets the navigate URL.
        /// </summary>
        /// <value>
        /// The navigate URL.
        /// </value>
        [Editor(typeof(UrlEditor), typeof(UITypeEditor))]
        public string NavigateUrl
        {
            get
            {
                return this.ViewState["NavigateUrl"] as string;
            }
            set
            {
                this.ViewState["NavigateUrl"] = value;
            }
        }

        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load"/> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs"/> object that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            this.Listeners.Click.Handler = string.Format("window.location = '{0}';",
                                                         this.Page.ResolveClientUrl(NavigateUrl));
        }
    }
}